﻿//using System.ComponentModel.DataAnnotations;
//using System.ComponentModel.DataAnnotations.Schema;

//namespace AyuBookmark.Common.Models
//{
//    [Table("categories")]
//    public class Category
//    {
//        [Key]
//        [Column("id")]
//        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
//        public int Id { get; set; }

//        [Required]
//        [Column("name")]
//        [StringLength(50)]
//        public string Name { get; set; }

//        [Column("color")]
//        [StringLength(7)]
//        public string Color { get; set; } = "#CCCCCC";

//        [Column("parent_id")]
//        public int? ParentId { get; set; }

//        [ForeignKey("ParentId")]
//        public virtual Category Parent { get; set; }

//        [Column("usage_count")]
//        public int UsageCount { get; set; }

//        [NotMapped]
//        public List<Category> Children { get; set; } = new List<Category>();
//    }
//}

// 文件路径：AyuBookmark.Common/Models/Category.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AyuBookmark.Common.Models
{
    /// <summary>
    /// 分类实体类
    /// </summary>
    [Table("categories")]
    public class Category
    {
        [Key]
        [Column("id")]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Required]
        [Column("name")]
        [StringLength(50)]
        public string Name { get; set; }

        [Column("color")]
        [StringLength(7)]
        public string Color { get; set; } = "#CCCCCC";

        [Column("parent_id")]
        public int? ParentId { get; set; }

        [Column("usage_count")]
        public int UsageCount { get; set; }

        [Column("last_used")]
        public DateTime? LastUsed { get; set; }

        [ForeignKey("ParentId")]
        public virtual Category Parent { get; set; }

        [NotMapped]
        public List<Category> Children { get; set; } = new List<Category>();
    }
}